package com.fank.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 *
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
//swagger2的配置文件，这里可以配置swagger2的一些基本的内容，比如扫描的包等等

    public Docket createApiRest(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.fank.spike.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    //构建api文档的详细信息函数，
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("springboot测试使用swagger2构建的restful文档")
                .contact(new Contact("fank","",""))
                .version("1.0.0")
                .description("接口文档描述")
                .build();
    }
}
